home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 6 / FM Towns Free Software Collection 6.iso / ms_dos / send_txt / send.asm next >
Encoding:
Assembly Source File  |  1993-07-08  |  7.2 KB  |  368 lines

  1. ;☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  2. ;
  3. ; 高速テキスト転送用コマンドプログラム V1.0c
  4. ;
  5. ; (パソコン通信に於ける高速テキスト転送等の用途用)
  6. ;
  7. ;
  8. ;
  9. ;
  10. ;  使用アセンブラ:Lucid ASSEMBLER&DEBUGGER
  11. ;
  12. ; 動作モード:8086以降-16ビット・リアルモード
  13. ;
  14. ; 作  成  者: Ken Inoue(HFH02366)
  15. ;
  16. ; 作成 日時: 1991年10月22日(火) 所要時間:約4日(含デバッグ)
  17. ;
  18. ;○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○○
  19. ;使用方法
  20. ;
  21. ;> SEND filename [ /L ]
  22. ;  オプションに"/L"を与えると、改行コードCR+LFにて送信。(デフォルトはCRのみ)
  23. ;☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆☆
  24.  
  25.  
  26. .use16
  27. .stack 256
  28.  
  29. ;======== CONSTANTS ========
  30.  
  31. cmdline        equ    80h
  32. BUFFER_SIZE    equ    1024*60    ;60KB
  33.  
  34. ;==============================================================================
  35. ;======== MAIN PROGRAM PROCEDURE ==============================================
  36. ;==============================================================================
  37.         ORG    100h
  38.  
  39. SEND_TXT    proc    near
  40. ;***** comment
  41.         mov    d_sp,sp
  42.         mov    sp,offset stack+(256-2)
  43.         pusha
  44.         mov    ah,9
  45.         mov    dx,offset str_o
  46.         int    21h        
  47.         mov    ah,9
  48.         mov    dx,offset str_o2
  49.         int    21h        
  50.         mov    ah,9
  51.         mov    dx,offset str_o3
  52.         int    21h        
  53.  
  54.         mov    si,cmdline+2
  55.         mov    di,offset file_name
  56.         xor    cx,cx
  57.         mov    cl,cmdline
  58. #cm_rd:        lodsb
  59.         cmp    al,0
  60.         je    short #cm_rd_end
  61.         cmp    al,0dh
  62.         je    short #cm_rd_end
  63.         cmp    al," "
  64.         je    short #cm_rd_end
  65.         stosb
  66.         loop    #cm_rd
  67. #cm_rd_end:    mov    al,0
  68.         stosb
  69.  
  70.         mov    bp,cmdline
  71.         xor    ax,ax
  72.         mov    al,[bp]
  73.         sub    si,80h
  74.         dec    si
  75.         cmp    ax,si
  76.         jle    short #no_option
  77.         mov    option_para,1
  78.  
  79. #no_option:    cmp    byte ptr [bp+1],20h
  80.         jge    short #opnfl
  81.         jmp    #quit__
  82.  
  83. ;***** open file
  84. #opnfl:        mov    dx,offset file_name
  85.         mov    ax,3d00h
  86.         int    21h
  87.         jnc    short #nxt0
  88.         jmp    #quit_
  89. #nxt0:        mov    file_handle,ax
  90.         mov    ah,9
  91.         mov    dx,offset str_file_check
  92.         int    21h        
  93.         call    get_filesize
  94.         call    COMMENT_SET
  95.  
  96.  
  97. ;***** Setting Terminal Mode
  98.         mov    ax,0200h
  99.         int    9bh
  100.         cmp    ah,4
  101.         jne    short #nxt1
  102.         jmp    #quit_
  103. #nxt1:        mov    ax,0400h
  104.         mov    di,offset terminal_para
  105.         int    9bh
  106.         or    byte ptr terminal_para,00010001b; x-flow control on
  107.         mov    word ptr terminal_para+6,50    ; 500[ms] <=time out
  108.         mov    ax,0300h
  109.         mov    di,offset terminal_para
  110.         int    9bh
  111.         mov    ax,0100h
  112.         int    9bh
  113.  
  114. ;***** ROUTINE OF SENDING TEXT DATA - MAIN ROUTINE *****
  115. ;***** comment
  116.         cmp    option_para,0
  117.         jne    short #msg2
  118. #msg1:        mov    ah,9
  119.         mov    dx,offset str_s1
  120.         int    21h        
  121.         jmp    short #msgx
  122. #msg2:        mov    ah,9
  123.         mov    dx,offset str_s2
  124.         int    21h        
  125. #msgx:        mov    ah,9
  126.         mov    dx,offset str_x1
  127.         int    21h
  128.  
  129.         mov    bp,option_para        ;for speed up & work
  130.  
  131. ;***** load file
  132.         mov    flag,0        ; flag of EOF.
  133.         even
  134. #load:        mov    ah,3fh
  135.         mov    bx,file_handle
  136.         mov    cx,BUFFER_SIZE
  137.         mov    dx,offset data_buffer
  138.         int    21h
  139.         mov    cx,ax
  140.         cmp    cx,BUFFER_SIZE
  141.         je    short #load_path
  142.         mov    flag,1
  143.         even
  144. #load_path:    mov    si,offset data_buffer    ;pointer
  145. ;***** send data to RS-232C port 0---------------------------------------------
  146.         even
  147. #loop_sd:    call    MESSAGE
  148.         mov    dl,[si]
  149.         inc    si
  150.         and    bp,bp
  151.         jnz    short #re
  152.         cmp    dl,0ah        ;LF code
  153.         jne    short #re    ;     cutting.
  154.         dec    cx
  155.         jz    short #ok_
  156.         jmp    short #loop_sd
  157. #re:        mov    ax,0700h
  158.         int    9bh        ;send
  159.         cmp    ah,4        ; guard for hung-up
  160.         je    short #quit2    ;
  161.         and    ah,ah
  162.         jz    short #ok
  163.         call    XFLOW_ON
  164. #ok:        loop    #loop_sd
  165. #ok_:        cmp    flag,0        ;Flag of buffer is full or no-full.
  166.         je    short #load
  167.  
  168. #finish:    mov    ah,9
  169.         mov    dx,offset str_f
  170.         int    21h        
  171. ;***** beep
  172.         mov    ah,0
  173.         int    9eh
  174.         mov    al,10
  175. #wai:        mov    cx,0ffffh
  176. #wait:        loop    #wait
  177.         dec    al
  178.         jne    short #wai
  179.         mov    ah,1
  180.         int    9eh
  181.  
  182. #quit:        mov    bx,file_handle
  183.         mov    ah,3eh
  184.         int    21h
  185.         popa
  186.         mov    sp,d_sp
  187.         mov    ax,4c00h
  188.         int    21h        
  189. #quit2:        mov    bx,file_handle
  190.         mov    ah,3eh
  191.         int    21h
  192.         mov    ah,9
  193.         mov    dx,offset str_q
  194.         int    21h
  195.         popa
  196.         mov    sp,d_sp
  197.         mov    ax,4c00h
  198.         int    21h        
  199. #quit_:        mov    ah,9
  200.         mov    dx,offset str_q
  201.         int    21h
  202.         popa
  203.         mov    sp,d_sp
  204.         mov    ax,4c00h
  205.         int    21h        
  206. #quit__:    mov    ah,9
  207.         mov    dx,offset str_inf
  208.         int    21h
  209.         popa
  210.         mov    sp,d_sp
  211.         mov    ax,4c00h
  212.         int    21h        
  213. SEND_TXT    endp
  214.  
  215. ;***** X-FLOW display routine.
  216.         even
  217. XFLOW_ON    proc    near
  218.         push    dx
  219.         mov    ah,9
  220.         mov    dx,offset str_x0
  221.         int    21h
  222.         pop    dx
  223.         even
  224. #re2:        push    dx
  225.         mov    ax,0900h
  226.         int    9bh
  227.         pop    dx
  228.         test    bh,101b
  229.         jz    short #re2
  230.         test    bl,10b
  231.         jz    short #re2
  232.         mov    ax,0700h    ;send data (dl=data)
  233.         int    9bh
  234.         mov    ah,9
  235.         mov    dx,offset str_x1
  236.         int    21h
  237.         ret
  238. XFLOW_ON    endp
  239.  
  240. ;***** GET FILE SIZE
  241.  
  242. get_filesize    proc    near
  243. #repeat:    mov    ah,3fh
  244.         mov    bx,file_handle
  245.         mov    cx,1024
  246.         mov    dx,offset data_buffer
  247.         int    21h
  248.         cmp    ax,1024
  249.         jl    short #return
  250.         inc    file_size
  251.         jmp    short #repeat
  252. #return:    mov    ax,4200h    ;file pointer offset
  253.         mov    bx,file_handle
  254.         xor    cx,cx
  255.         xor    dx,dx
  256.         int    21h
  257.         ret
  258. get_filesize    endp
  259.  
  260. ;***** MESSAGE DISPLAY routine
  261.         even
  262. MESSAGE        proc    near
  263.         inc    data_size1
  264.         cmp    data_size1,1024
  265.         je    short #display
  266.         ret
  267.         even
  268. #display:    mov    word ptr data_size1,0
  269.         inc    data_size2
  270.         xor    dx,dx
  271.         mov    ax,data_size2
  272.         and    ax,ax
  273.         jz    short #qut
  274.         div    div10
  275.         add    dl,"0"
  276.         mov    str_x1+29,dl
  277.         xor    dx,dx        ;
  278.         and    ax,ax        ;
  279.         jz    short #qut    ;
  280.         div    div10        ;
  281.         add    dl,"0"        ;
  282.         mov    str_x1+28,dl    ;
  283.         xor    dx,dx
  284.         and    ax,ax
  285.         jz    short #qut
  286.         div    div10
  287.         add    dl,"0"
  288.         mov    str_x1+27,dl
  289.         xor    dx,dx        ;
  290.         and    ax,ax        ;
  291.         jz    short #qut    ;
  292.         div    div10        ;
  293.         add    dl,"0"        ;
  294.         mov    str_x1+26,dl    ;
  295. #qut:        mov    ah,9
  296.         mov    dx,offset str_x1
  297.         int    21h
  298.         ret
  299. MESSAGE        endp
  300.  
  301. ;***** COMMENT SET
  302.         even
  303. COMMENT_SET    proc    near
  304.         xor    dx,dx
  305.         mov    ax,file_size
  306.         and    ax,ax
  307.         jz    short #qui
  308.         div    div10
  309.         add    dl,"0"
  310.         mov    str_x1+34,dl
  311.         xor    dx,dx        ;
  312.         and    ax,ax        ;
  313.         jz    short #qui    ;
  314.         div    div10        ;
  315.         add    dl,"0"        ;
  316.         mov    str_x1+33,dl    ;
  317.         xor    dx,dx
  318.         and    ax,ax
  319.         jz    short #qui
  320.         div    div10
  321.         add    dl,"0"
  322.         mov    str_x1+32,dl
  323.         xor    dx,dx        ;
  324.         and    ax,ax        ;
  325.         jz    short #qui    ;
  326.         div    div10        ;
  327.         add    dl,"0"        ;
  328.         mov    str_x1+31,dl    ;
  329. #qui:        ret
  330. COMMENT_SET    endp
  331.  
  332. ;======== WORK AREA ========
  333.         even
  334. file_handle    dw    ?
  335. file_name    db    80h dup (?)
  336. terminal_para    db    12h dup (?)
  337. option_para    dw    0        ; 0 or 1
  338.  
  339. ;======== MESSAGES ========
  340. str_o        db    0dh
  341. db    "Hi-SPEED TEXT FILE UPLOADING COMMAND  Version 1.0c ",0dh,0ah,"$"
  342. str_o2        db    "Programed by Ken Inoue.(C)1991 ",0dh,0ah,"$"
  343. str_o3        db    0dh,0ah,"$"
  344. str_file_check    db    "Now get a file size!",0dh,"$"
  345. str_s1        db    "高速転送処理中(LineEnd=CR)",0dh,0ah,"$"
  346. str_s2        db    "高速転送処理中(LineEnd=CR+LF)",0dh,0ah,"$"
  347. str_f        db    0dh,0ah,"転送完了しました。",0dh,0ah,"$"
  348. str_q    db    0dh,0ah,"エラー発生の為、処理を中断しました。",0dh,0ah,"$"
  349. str_inf        db    0dh,0ah,"----- 御使用方法 -----",0dh,0ah,0dh,0ah
  350.         db    "(1) SEND filename    --- 改行コードCRのみ",0dh,0ah
  351.         db    "(2) SEND filename /L --- 改行コードCR+LF",0dh,0ah
  352.         db    0dh,0ah,"上記の様に呼出しを行ってください",0dh,0ah,"$"
  353. str_x0        db    "Now  ",1bh,"[31;7mWAIT!",1bh,"[0m ",0dh,"$"
  354. str_x1        db    "Now ",1BH,"[36;7mSENDING",1BH,"[0m : ("
  355.         db    0,0,0,"0/",0,0,0,"0KB)",0dh,"$"
  356.  
  357. ;======== work (^_^;) ========
  358.         align    2
  359. div10        dw    10
  360. data_size1    dw    0
  361. data_size2    dw    0
  362. file_size    dw    0
  363. flag        db    ?
  364. d_sp        dw    ?
  365. stack        db    256 dup(?)
  366. data_buffer    label    far    ;BUFFER SIZE dup (?) ;(^^;)
  367.         end    SEND_TXT
  368.